$(function () {
    bindDeleteEvent();
    bindDeleteConfirmEvent();
});

function bindDeleteEvent() {
    $('.btn-delete').click(function () {
            // {#清空上次报错信息#}
            $('#deleteError').text()

            $('#modalDeleteConfirm').modal('show')
            DELETE_ID = $(this).attr('cid')
        }
    );
}

function bindDeleteConfirmEvent() {
    $('.btnDeleteConfirm').click(function () {
        $.ajax({
            url: DELETE_URL,
            type: "GET",
            data: {cid: DELETE_ID},
            dataType: 'JSON',
            success: function (res) {
                if (res.status) {
                    // {#删除页面数据#}
                    // {#方式一：刷新页面#}
                    // {#location.reload()#}
                    // {#方式二：删除当前页面html对应标签#}
                    $("tr[row-id='" + DELETE_ID + "']").remove()

                    $('#modalDeleteConfirm').modal('hide')
                } else {
                    $('#deleteError').text(res.detail)
                }
            }
        })
    })
}